home *** CD-ROM | disk | FTP | other *** search
-
-
- #ifndef FRCAR_H
- #define FRCAR_H
-
- #include <Engine/Engine.h>
-
- typedef struct
- {
- Float fRPMChange; // RPM change per second if pedal is fully pressed
- Float fRPMTrans; // Acceleration = fRPMTrans * RPM
-
- }FRGearInfo;
-
- class FRCarLight;
- class FRCarDecal;
-
- #define FIRST_GEAR 1
- #define SECOND_GEAR 2
- #define THIRD_GEAR 3
- #define FOURTH_GEAR 4
- #define FIFTH_GEAR 5
- #define SIXTH_GEAR 6
- #define REVERSE_GEAR 0
- #define NEUTRAL_GEAR -1
-
- #define MAX_TYRE_DECAL_LENGTH 20.0f
- #define MIN_DECAL_SPEED 55.0f
-
- #define MAX_LIGHT_SIZE 16.0f
- #define MIN_LIGHT_SIZE 6.0f
-
- enum FRCarType{AI = 0, LOCAL = 1, NETWORK = 2};
- enum FRCarVisibility{NORMAL = 0, INVISIBLE = 1, BLINKING = 2};
- enum FRCarState{RACING = 0, FINISHED1ST = 1, FINISHED2ND = 2, FINISHED3RD,
- FINISHED4TH = 4, DESTROYED = 5, WAITING = 6, KO = 7};
-
- class FRCar : public TEEngineObject
- {
- TERTTIDeclaration;
-
- public:
-
- FRCar();
-
- ~FRCar();
-
- virtual void Horn(void);
-
- void SetHandbrake(bool bBrake){m_bHandbrake = bBrake;}
- bool GetHandbrake(void){return m_bHandbrake;}
- void SetPedal(Float fPedal);
- Float GetPedal(void){return m_fPedal;}
- void SetSteeringWheel(Float fWheel);
- Float GetSteeringWheel(void){return m_fSteeringWheel;}
-
- Float GetRPM(void){return m_fCurrentRPM;}
- Int32 GetGear(void){return m_lCurrentGear;}
-
- Float GetSpeedKMH(void);
-
- void SetPowerUp(UInt32 lPowerUp);
- void EnablePowerUp(void);
-
- void EMPHit(void);
- void OilHit(void);
-
- TEString m_DriverName;
- UInt32 m_ulAINode;
- UInt32 m_ulLastAINodeChange;
- Float m_fAIEfficiency;
- UInt32 m_ulTrackNode;
- UInt32 m_ulLap;
- bool m_bAIUsesHorn;
- FRCarType m_Type;
- FRCarState m_State;
- FRCarVisibility m_Visibility;
-
- UInt32 m_ulLastReset;
-
- Int32 m_lPowerUp;
- UInt32 m_ulPowerUpEndTime;
- Int32 m_lPowerUpInfluence;
-
- static bool ms_bPowerUpsEnabled;
- static bool ms_bTyreDecals;
- static bool ms_bSmoke;
-
- protected:
-
- friend class FRApp;
-
- TESoundReference* m_pPickup;
- TESoundReference* m_pFire;
-
- TESoundReference* m_pMotor;
- TESoundReference* m_pBraking;
- TESoundReference* m_pHorn;
-
- TETextureReference* m_pFrontLight;
- TETextureReference* m_pBackLight;
-
- bool m_bHandbrake;
- Float m_fPedal; // 1.0f = driving forward -1.0 = braking
- Float m_fSteeringWheel; // -1.0f = full left 1.0f = full right
-
- TEVector m_Forward;
- TEVector m_Up;
- TEVector m_Right;
- TEVector m_CarSize;
- Float m_fDeltaY;
-
- Float m_fMaxRPM;
- Float m_fRotFactor;
- UInt32 m_ulNumGears;
- FRGearInfo* m_aGears;
-
- Float m_fCurrentRPM;
- Int32 m_lCurrentGear;
-
- Float m_fFrontAxis; // Distance from Center to front axis
- Float m_fRearAxis; // " " rear axis
-
- bool m_bBraking;
-
- Float m_fWheelWidth;
- Float m_fWheelMov;
-
- TEVector m_DecalForward; // stuff for managing tyre decals
- TEVector m_DecalStartLeft;
- TEVector m_DecalStartRight;
- // TEVector m_DecalNormalLeft;
- // TEVector m_DecalNormalRight;
- Float m_fDecalLengthLeft;
- Float m_fDecalLengthRight;
- FRCarDecal* m_pDecalLeft;
- FRCarDecal* m_pDecalRight;
-
- Float m_fBrakeEfficiency;
-
- TEVector m_aLightPos[4]; // Relative position of lights
-
- UInt16 m_usNumExhaust;
- TEParticleFX* m_aExhaust[2];
- TEVector m_aExhaustPos[2];
-
- virtual void Render(TERenderer* pRender, TECamera* pCam);
- virtual void RenderShadow(TERenderer* pRender, TECamera* pCam, TELight* pLights,
- TEShadowMethod DefaultMethod, bool bMoreThanOneShadow);
- virtual void Animate(UInt32 ulDeltaT, TEEngine* pEngine);
- virtual void Update(UInt32 ulDeltaT, TEEngine* pEngine);
- virtual bool Influence(UInt32 ulDeltaT, TEEngineObject* pObject);
- virtual void OnClip(TEEngineObject* pInfluencer);
-
- void UpdateEngine(UInt32 ulDeltaT, TEEngine* pEngine);
-
- void UpdateVectors(void);
-
- void Reset(TEVector &rCenter, TEVector &rNormal);
- private:
-
- void CreateTyreDecals(UInt32 ulDeltaT, TEEngine* pEngine);
- };
-
- class FRCarDecal : public TEDecal
- {
- public:
-
- FRCarDecal(TEVector &rPos, TEVector &rForward, Float fLength, Float fWidth)
- {
- TEString Name = "tyre";
- UChar aucColorKey[] = {255, 255, 255};
-
- m_usNumVerts = 6;
- m_aVerts = new TEVertex[6];
- m_pTexture = TETextureManager::GetTextureManager()->GetTexture(Name, Name, false, aucColorKey);
- m_ucAlpha = 220;
- m_bColorKeyed = true;
- m_aucColor[0] = m_aucColor[1] = m_aucColor[2] = 0;
- m_bFadeBeforeDeath = true;
- m_ulFadingStart = 1000;
- m_usSrcBlend = BLEND_SRC_ALPHA;
- m_usDstBlend = BLEND_ONE_MINUS_SRC_ALPHA;
- m_pNext = NULL;
-
- SetData(rPos, rForward, fLength, fWidth);
- }
-
- void SetData(TEVector &rPos, TEVector &rForward, Float fLength, Float fWidth)
- {
- TEVector Vec;
- TEVector Right, Up;
- // TEVector Normal = TEVector(0.0f, 1.0f, 0.0f);
-
- m_ulCreationTime = TETimer::GetTimer()->GetTime();
- m_ulMaxLifeTime = 30000;
-
- // Right = Normal.CrossProduct(rForward);
- // Up = Right.CrossProduct(Normal) * fLength;
- Right = TEVector(rForward.m_fZ, 0.0f, -rForward.m_fX);
- Up = TEVector(rForward.m_fX * fLength, 0.0f, rForward.m_fZ * fLength);
- Right = Right * fWidth * 0.5f;
-
- Vec = rPos - Right + Up;
- m_aVerts[0] = m_aVerts[3] = TEVertex(Vec.m_fX, Vec.m_fY, Vec.m_fZ, 0.0f, 0.0f);
-
- Vec = rPos + Right;
- m_aVerts[1] = m_aVerts[5] = TEVertex(Vec.m_fX, Vec.m_fY, Vec.m_fZ, 1.0f, fLength * 0.5f);
-
- Vec = rPos - Right;
- m_aVerts[2] = TEVertex(Vec.m_fX, Vec.m_fY, Vec.m_fZ, 0.0f, fLength * 0.5f);
-
- Vec = rPos + Right + Up;
- m_aVerts[4] = TEVertex(Vec.m_fX, Vec.m_fY, Vec.m_fZ, 1.0f, 0.0f);
-
- m_Center = rPos;
-
- m_BSphere.UpdateVolume(m_aVerts, m_usNumVerts);
- m_bUseCulling = (m_BSphere.GetVolume() > 200);
- }
- };
-
- #endif
-
-